﻿using System;
using System.Collections.Generic;

namespace Terraria.ModLoader
{
	// Token: 0x02000174 RID: 372
	public static class UgBgStyleLoader
	{
		// Token: 0x06000F1A RID: 3866 RVA: 0x00401334 File Offset: 0x003FF534
		internal static int ReserveBackgroundSlot()
		{
			int result = UgBgStyleLoader.nextUgBgStyle;
			UgBgStyleLoader.nextUgBgStyle++;
			return result;
		}

		// Token: 0x06000F1B RID: 3867 RVA: 0x0000E506 File Offset: 0x0000C706
		public static ModUgBgStyle GetUgBgStyle(int style)
		{
			if (style < 18 || style >= UgBgStyleLoader.nextUgBgStyle)
			{
				return null;
			}
			return UgBgStyleLoader.ugBgStyles[style - 18];
		}

		// Token: 0x06000F1C RID: 3868 RVA: 0x00006B58 File Offset: 0x00004D58
		internal static void ResizeAndFillArrays()
		{
		}

		// Token: 0x06000F1D RID: 3869 RVA: 0x0000E525 File Offset: 0x0000C725
		internal static void Unload()
		{
			UgBgStyleLoader.nextUgBgStyle = 18;
			UgBgStyleLoader.ugBgStyles.Clear();
		}

		// Token: 0x06000F1E RID: 3870 RVA: 0x00401354 File Offset: 0x003FF554
		public static void ChooseStyle(ref int style)
		{
			if (!GlobalBgStyleLoader.loaded)
			{
				return;
			}
			foreach (ModUgBgStyle modUgBgStyle in UgBgStyleLoader.ugBgStyles)
			{
				if (modUgBgStyle.ChooseBgStyle())
				{
					style = modUgBgStyle.Slot;
				}
			}
			foreach (GlobalBgStyleLoader.DelegateChooseUgBgStyle delegateChooseUgBgStyle in GlobalBgStyleLoader.HookChooseUgBgStyle)
			{
				delegateChooseUgBgStyle(ref style);
			}
		}

		// Token: 0x06000F1F RID: 3871 RVA: 0x004013D4 File Offset: 0x003FF5D4
		public static void FillTextureArray(int style, int[] textureSlots)
		{
			if (!GlobalBgStyleLoader.loaded)
			{
				return;
			}
			ModUgBgStyle ugBgStyle = UgBgStyleLoader.GetUgBgStyle(style);
			if (ugBgStyle != null)
			{
				ugBgStyle.FillTextureArray(textureSlots);
			}
			foreach (Action<int, int[]> action in GlobalBgStyleLoader.HookFillUgTextureArray)
			{
				action(style, textureSlots);
			}
		}

		// Token: 0x040012A5 RID: 4773
		public const int vanillaUgBgStyleCount = 18;

		// Token: 0x040012A6 RID: 4774
		private static int nextUgBgStyle = 18;

		// Token: 0x040012A7 RID: 4775
		internal static readonly IList<ModUgBgStyle> ugBgStyles = new List<ModUgBgStyle>();
	}
}
